package com.jpemartin.jgt;

import java.awt.*;

/** Draw the given text with the given color. Typically you'd only use the ctor
 *  and the draw(g,x,y) methods. */
public class DrawText implements Drawable {

   protected String _text;
   protected Color _color;
   
   /** Initialize the object with a given text and color */
   public DrawText(String text, Color color) {
      if (null==text || null==color) throw new NullPointerException("DrawText does not accept null parameters");
      _text = text;
      _color = color;
   }
   
   /** @return the color of the text */
  public Color getColor() {
     return _color;
  }

  /** Set the text color */
  public void setColor(Color _color) {
     this._color = _color;
  }
  
   /** draw the text at the given position, using the default font */
   public void draw(Graphics g, int x, int y) {
      g.setColor(_color);
      g.drawString(_text,x,y);
   }
   
   /** draw the text at the given position, using the default font, but with a different color */
   public void draw(Graphics g, int x, int y, Color colorOverride) {
      g.setColor(colorOverride);
      g.drawString(_text,x,y);
   }

}
